package band.wukong.practice.javase.core.io.readerandwriter;

import java.io.CharArrayReader;
import java.io.CharArrayWriter;

/**
 * Desc:
 * Author: sunjs
 * Date: 2009-11-16 16:04:45
 */
public class TestCharArrayRW {
    public static void main(String[] args) throws Exception {
        testWriter();
    }

    public static void testReader() throws Exception {
        char[] buff = new char[]{'a', '道', '名', '1'};
        CharArrayReader reader = new CharArrayReader(buff);
        int data;
        while ((data = reader.read()) != -1) {
            System.out.print((char) data + " ");
        }
        reader.close(); //close方法不执行任何操作
    }

    public static void testWriter() throws Exception {
        CharArrayWriter writer = new CharArrayWriter();
        writer.write("精");
        writer.write("诚");
        char[] buff = writer.toCharArray();
        System.out.println(new String(buff));
        writer.close();
    }
}
